<template>
  <div class="my">
    <div class="top" v-if="bol">
      <div class="top1">
        <div class="left">
          <img
            class="left1"
            v-if="users.photo"
            :src="users.photo"
            alt=""
            @click="userClick"
          />
          <img class="left1" v-else src="@/assets/avatar.jpg" alt="" />
          <div class="left2">
            <div class="left-name">{{ users.name }}</div>
            <div class="left-text">申请认证</div>
          </div>
        </div>
        <div class="right">
          <div class="book">
            <van-icon name="notes-o" color="#ffffff" />
          </div>
          <div>
            <div class="read">今日阅读</div>
            <div class="times">5分钟</div>
          </div>
        </div>
      </div>
      <ul class="top2">
        <li class="top2-item">
          <div class="num">{{ users.art_count }}</div>
          <div class="txt">动态</div>
        </li>
        <li class="top2-item">
          <div class="num">{{ users.follow_count }}</div>
          <div class="txt">关注</div>
        </li>
        <li class="top2-item">
          <div class="num">{{ users.fans_count }}</div>
          <div class="txt">粉丝</div>
        </li>
      </ul>
    </div>
    <div class="middle">
      <ul class="middle-item">
        <li class="item1">
          <i class="icons">
            <van-icon name="star-o" color=" #eb5253" />
          </i>
          <div class="txt1">收藏</div>
        </li>
        <li class="lines"></li>
        <li class="item1">
          <i class="icons1">
            <van-icon name="underway-o" color=" #ff9d1d" />
          </i>
          <div class="txt1">历史</div>
        </li>
        <li class="lines"></li>
        <li class="item1">
          <i class="icons2">
            <van-icon name="edit" color="#678eff" />
          </i>
          <div class="txt1">作品</div>
        </li>
      </ul>
      <div class="content">
        <MyCell title="消息通知"></MyCell>
        <MyCell title="实名认证"></MyCell>
      </div>
      <div class="fotter">
        <MyCell title="用户反馈"></MyCell>
        <MyCell title="小智同学"></MyCell>
        <MyCell title="系统设置"></MyCell>
      </div>
    </div>
    <div class="out">
      <van-button
        class="out1"
        type="primary"
        color="#439ffa"
        block
        @click="outClick"
        >退出</van-button
      >
    </div>
  </div>
</template>

<script>
// 导入axios
// import axios from 'axios'
// 导入token
import { removeLocalToken } from '@/utils/token.js'
// 导入获取个人信息的api
import { appV10User } from '@/api/login.js'

import MyCell from './MyCell'
export default {
  name: 'My',
  data () {
    return {
      bol: true,
      users: {}
    }
  },
  components: {
    MyCell
  },
  async created () {
    this.$nextTick(() => {
      this.bol = true
    })
    const res = await appV10User()
    // const res = await axios({
    //   url: 'http://ttapi.research.itcast.cn/app/v1_0/user',
    //   method: 'get',
    //   headers: {
    //     'Content-Type': 'application/json',
    //     authorization: `${getLocalToken('token')}`
    //       ? `Bearer ${getLocalToken('token')}`
    //       : 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NDMyODQzNjYsInVzZXJfaWQiOjF9.mLYitrKsn4E4KdQd0CNPugKrH8uQmXEQTlG_JutC8jU'
    //   }
    // })
    console.log(res)
    this.users = res.data
    console.log(this.users.name)
  },
  mounted () {},
  methods: {
    userClick () {
      this.$router.push('/home/info')
    },
    outClick () {
      removeLocalToken('token')
      //   修改登录状态
      this.$store.commit('setIsLogin', false)
      this.$router.push('/login')
    }
  }
}
</script>

<style lang="less" scoped>
.my {
  height: 100%;
  background-color: #f5f7f9;

  .top {
    background: @color-bg;
    padding-top: 29px;
    position: relative;

    .top1 {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding-left: 20px;

      .left {
        flex: 1;
        display: flex;

        .left2 {
          // vertical-align: middle;
          flex: 1;

          .left-name {
            font-family: MicrosoftYaHei;
            font-size: 16px;
            line-height: 33px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #ffffff;
          }

          .left-text {
            width: 58px;
            height: 16px;
            line-height: 12px;
            border: 1px solid #ffffff;
            background-color: #ffffff;
            border-radius: 8px;
            font-family: MicrosoftYaHei-Bold;
            font-size: 12px;
            text-align: center;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #3296fa;
          }
        }

        .left1 {
          // padding-left: 20px;
          margin-right: 20px;
          width: 60px;
          height: 60px;
          background-color: #ffffff;
          border: solid 1px #ffffff;
          border-radius: 50%;
        }
      }

      .right {
        padding-left: 40px;
        padding-top: 5px;
        width: 94px;
        height: 40px;
        margin: 0 auto;
        background-color: #3b82c9;
        border-top-left-radius: 20px;
        border-bottom-left-radius: 20px;
        position: relative;
        align-items: center;
        // opacity: 0.2;
        .book {
          position: absolute;
          left: 5px;
          top: 5px;
        }

        .read {
          font-family: MicrosoftYaHei;
          font-size: 11px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #ffffff;
        }

        .times {
          font-family: MicrosoftYaHei;
          font-size: 11px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #ffffff;
        }
      }
    }

    .top2 {
      margin-top: 28px;
      padding-bottom: 16px;
      display: flex;
      justify-content: space-around;

      .top2-item {
        text-align: center;

        .num {
          font-family: ArialMT;
          font-size: 16px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #ffffff;
        }

        .txt {
          padding-top: 8px;
          font-family: MicrosoftYaHei;
          font-size: 12px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #ffffff;
        }
      }
    }
  }

  .middle {
    .middle-item {
      padding: 15px 20px;
      display: flex;
      background-color: #ffffff;
      // margin-top: 5px;
      margin-bottom: 5px;
      justify-content: space-around;

      .item1 {
        text-align: center;

        .txt1 {
          font-family: MicrosoftYaHei;
          font-size: 16px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #333333;
        }
      }

      .lines {
        height: 47px;
        width: 1px;
        background-color: #f2f3f6;
      }
    }
  }

  .content {
    margin-bottom: 5px;
  }

  .fotter {
    margin-bottom: 5px;
    padding-bottom: 5px;
  }
  .out {
    padding: 0 20px;
    .out1 {
      border-radius: 8px;
      font-size: 20px;
      font-weight: 700;
      background: @color-bg !important;
    }
  }
}
</style>
